<template>
  <el-form ref="form" :model="form" label-width="80px" label-position='top'>
    <div style="height:80px;border: 1px solid #DCDFE6;border-radius: 5px;margin-bottom:15px;display: flex;align-items: center;justify-content: space-between;">
      <div style="flex: 1;">
        <el-form-item style="margin-bottom:0;border-bottom: 1px solid #DCDFE6;">
          <span style="display: inline-block;padding:0 15px;color: #ccc;">从</span>
          <span>{{form.type==1?'商家账户':'个人账户'}}</span>
        </el-form-item>
        <el-form-item style="margin-bottom:0;">
          <span style="display: inline-block;padding:0 15px;color: #ccc;">到</span>
          <span>{{form.type==2?'商家账户':'个人账户'}}</span>
        </el-form-item>
      </div>
      <div @click="zhuanhuan" style="background-color: #F5F7FA;width: 100px;height: 100%;border-left: 1px solid #DCDFE6;display: flex;align-items: center;justify-content: center;">
        <i class="el-icon-sort" style="font-size: 24px;color: #03a9f4;font-weight: bold;"></i>
      </div>
    </div>
    
    <el-form-item label="划转数量">
      <el-input-number v-model="form.goldenBeans" :min="0"></el-input-number>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">确认</el-button>
    </el-form-item>
  </el-form>
</template>
<script>
export default {
  data () {
    return {
      form: {
        goldenBeans: 0,
        type: 1
      },
    }
  },
  methods: {
    zhuanhuan(){
      this.form.type == 1?this.form.type = 2:this.form.type = 1;
    },
    onSubmit() {
      this.$http.post(this.$api.goldenBeanTransfer, this.form).then(res => {
        if (res.code == 0) {
          this.$message({
            type: 'success',
            message: '金豆划转成功！'
          })
         
          this.$emit('success')
        } else {
          this.$emit('error')
          this.$message.error('金豆划转失败！' + res.msg)
        }
      })
    },
  }
}
</script>